#include <iostream>
#include <fstream>
#include <string>
   // 如果没有找到漂流瓶，返回一个空的漂流瓶
    MessageInBottle emptyBottle;
    return emptyBottle;


int main() {
    std::string filePath = "bottles.txt"; // 漂流瓶文件路径
    
    // 主循环
    while (true) {
        int choice;
        std::cout << "漂流瓶程序" << std::endl;
        std::cout << "1. 扔出漂流瓶" << std::endl;
        std::cout << "2. 捡起漂流瓶" << std::endl;
        std::cout << "3. 退出" << std::endl;
        std::cout << "请选择操作：";
        std::cin >> choice;
        std::cin.ignore(); // 忽略换行符

        switch (choice) {
            case 1: {
                std::string content, sender;
                std::cout << "请输入漂流瓶内容：";
                std::getline(std::cin, content);
                std::cout << "请输入你的名字（作为发送者）：";
                std::getline(std::cin, sender);
                throwBottle(content, sender);
                break;
            }
            case 2: {
                MessageInBottle pickedBottle = pickUpBottle();
                if (!pickedBottle.content.empty()) {
                    std::cout << "你捡到了一个漂流瓶，内容是：" << pickedBottle.content << std::endl;
                    std::cout << "发送者：" << pickedBottle.sender << std::endl;
                } 
				else {
                    std::cout << "没有漂流瓶可捡。" << std::endl;
                }
                break;
            }
            case 3: {
                std::cout << "程序退出。" << std::endl;
                return 0; // 退出程序
            }
            default: {
                std::cout << "无效的选择，请重新输入。" << std::endl;
                break;
            }
        }
    }

    return 0;
}